/**
 * 常规工作时间向导
 */
Ext.namespace("Ext.ux.workholiday");

Ext.ux.workholiday.RegularWorkTimeSetWizard = Ext.extend(Ext.ux.Wiz, {

	title: '设置工作日和工作时间段向导',
	width: 800,
	height: 360,
	
	cardPanelConfig: { 
		defaults: {
			bodyStyle: 'padding:40px 30px 5px 30px;background-color:#F6F6F6;', 
			border: false     
		}
	},

	initComponent: function(){
	
		//配置向导每个cards的提示信息
		var wizardInfoOfCards = new Array();
		wizardInfoOfCards[0] = "<span style='font-family:verdana;font-size:120%'>第一步：设置工作日</span><br><br><span style='font-size:100%;color: gray'>&nbsp;请选定一周中哪些天是常规工作日。</span>";
		wizardInfoOfCards[1] = "<span style='font-family:verdana;font-size:120%'>第二步：设定工作时间段</span><br><br><span style='font-size:100%;color: gray'>&nbsp;请为每个工作日设置工作时间段。</span>";
		this.wizardInfoOfCards = wizardInfoOfCards;
	
		this.initCards();
		
		Ext.ux.workholiday.RegularWorkTimeSetWizard.superclass.initComponent.call(this);
		
	},
	initCards: function(){
		var card1 = new Ext.ux.workholiday.WorkDaySetPanel({wizardWin:this});
		var card2 = new Ext.ux.workholiday.WorkTimeSetPanel({wizardWin:this});
		var cards = new Array();
		cards[0] = card1;
		cards[1] = card2;
		this.cards = cards;
	},
	
	//单击下一步
	onNextClick: function(){
		 if(this.currentCard == 0){
		 	this.cards[0].calSelWorkDays();
		 }
         Ext.ux.workholiday.RegularWorkTimeSetWizard.superclass.onNextClick.call(this);
	},
	getWorkDays: function(){
		return this.cards[0].getWorkDays();
	},
	onFinish: function(){
		var wizardWin = this.cards[1].wizardWin;
		if(this.cards[1].isValid()){
			
			this.cards[1].getForm().submit({
				url: '/framework/workdayholiday/wh-regular-work-time!setRegularWorkTime.action',
				success: function(){
					Ext.Msg.alert('系统提示','成功完成工作日与工作时间设定');
					Ext.getCmp('regularWorkTimeGrid').getStore().reload();
					Ext.ux.workholiday.RegularWorkTimeSetWizard.superclass.onFinish.call(wizardWin);
				},
				failure: function(){
					Ext.Msg.alert('系统提示','设置工作日与工作时间失败！');
				}
			});
		}
		else{
			Ext.Msg.alert('系统提示', '某个时间段的起始时间大约结束时间！');
		}
	}
});